package com.sy.sevice.impl;

import com.sy.constant.BusinessConstant;
import com.sy.dto.JsonResult;
import com.sy.mapper.AnnouncementMapper;
import com.sy.sevice.AnnouncementService;
import com.sy.vo.AnnouncementInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Yasuda-T
 * @version 1.0
 * @date 2020/9/14 17:03
 * @usage
 */
@Service
public class AnnouncementServiceImpl implements AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;

    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public JsonResult changeNoticeInfo(AnnouncementInfoVo avo, Integer id, Integer teacherId) {
        String title = avo.getTitle();
        String content = avo.getContent();
        Integer rows = announcementMapper.changeNoticeInfo(title, content, teacherId, id);
        System.out.println("受影响的行数:" + rows);
        return JsonResult.buildSuccess(200);
    }

    @Override
    public JsonResult delNotice(Integer id, Integer state) {
        Integer rows = announcementMapper.delNotice(id, state);
        System.out.println("受影响的行数:" + rows);
        return JsonResult.buildSuccess(200);
    }
}
